package top.yueyazhui.dds.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yueyazhui.dds.annotation.DataSource;
import top.yueyazhui.dds.mapper.UserMapper;
import top.yueyazhui.dds.model.User;
import top.yueyazhui.dds.service.IUserService;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    UserMapper userMapper;
    @Autowired
    UserServiceImpl userService;

    @Override
    @DataSource("slave")
    public List<User> getAllUser() {
        return userMapper.getAllUser();
    }

    @Override
//    @DataSource("slave")
    public List<User> getAllUser1() {
        List<User> allUser = getAllUser();
        // 循环依赖，解决业务层相互调用，注解失效问题（知识点：动态代理）
//        allUser = userService.getAllUser();
        return allUser;
    }
}
